package ru.evga.inse.core.dao;

import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;

import ru.evga.inse.core.domain.BaseEntity;


public interface IDao<K, E extends BaseEntity>
{
    
    Class<E> getEntityClass();

    E find(Long id) throws DaoException;
    
    E persist(E entity);
    
    void remove(E entity) throws DaoException;
    
    void remove(Long id) throws DaoException;

    void flush();

    E merge(E entity);

//    IResultContainer<E> findRange(final Integer firstResult, final Integer maxResults, final String orderBy, final Boolean isAsc) throws DaoException;

    Long count();

    E getReference(Long id) throws DaoException;

    E getReference(E entity) throws DaoException;
    
    
    /*----------------------*/
    CriteriaQuery<E> crateCriteriaQuery();
    
    CriteriaBuilder getCriteriaBuilder();
    
    void assertEntityHasField(String field) throws DaoException;
    
    EntityManager getEntityManager();
}
